#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int rearrangeCharacters(string s, string target)
    {
        int hash[26] = {0};
        for (auto e : s)
        {
            hash[e - 'a']++;
        }
        int count = 0;
        while (true)
        {
            for (auto e : target)
            {
                hash[e - 'a']--;
                if (hash[e - 'a'] < 0)
                {
                    return count;
                }
            }
            ++count;
        }
        return count;
    }
};